﻿#pragma once


#ifdef AS_REDIS
#include <string>
class RedisException : public std::exception
{
public:
	RedisException(const char *msg, int err_num)
	{
		if (msg)
			err_info_ = "Redis exception:" + std::string(msg);
		else
			err_info_ = "Unknown exception...";

		switch (err_num)
		{
		case REDIS_ERR_PROTOCOL:
		case REDIS_ERR_OOM:
		case REDIS_ERR_OTHER:
		{
			err_info_.append(" redis error");
			break;
		}
		case REDIS_ERR_IO:
		case REDIS_ERR_EOF:
		case REDIS_ERR_TIMEOUT:
		{
			err_info_.append(" redis timeout");
			break;
		}
		default:
			break;
		}
	}

	virtual ~RedisException() {}
	virtual char const *what() const
	{
		return 	err_info_.c_str();
	}

	std::string err_info_;
};





















#endif
